package com.sbio.udiapp.util;

import static com.blankj.utilcode.util.StringUtils.getString;

import android.content.Context;
import android.content.SharedPreferences;

import androidx.preference.PreferenceManager;

import com.sbio.udiapp.R;
import com.sbio.udiapp.di.ActivityManager;

public class DefaultSharedPreferencesUtil {

//    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
//    String useDept = preferences.getString(getString(R.string.use_dept), "");
//            if (CollectionUtils.isEmpty(datas) && useDept.equals(getString(R.string.use_dept_produce))) {
//        data0 = datas.get(0);
//    }



    /**
     * 使用部门是否为生产部门
     *
     * @return
     */
    public static boolean useDeptIsProduct(Context context) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String useDept = preferences.getString(getString(R.string.use_dept), getString(R.string.use_dept_produce));
        return useDept.equals(getString(R.string.use_dept_produce));

    }

    /**
     * 获取设备编码
     *
     * @return
     */
    public static String getDeviceNo(Context context) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        return preferences.getString(getString(R.string.device_no), "");

    }

    /**
     * 获取设备编码
     *
     * @return
     */
    public static String getDeviceNo() {
        Context context = ActivityManager.getCurrentActivity();
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        return preferences.getString(getString(R.string.device_no), "");

    }


    /**
     * 获取使用部门
     *
     * @return
     */
    public static String getUseDept(Context context) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String useDept = preferences.getString(getString(R.string.use_dept), getString(R.string.use_dept_produce));
        return useDept;

    }

    /**
     * 获取使用部门
     *
     * @return
     */
    public static String getUseDept() {
        Context context = ActivityManager.getCurrentActivity();
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String useDept = preferences.getString(getString(R.string.use_dept), getString(R.string.use_dept_produce));
        return useDept;

    }
}
